package com.smartthinking.CICPNL.home.activity;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Dictionary;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.smartthinking.CICPNL.R;
import com.smartthinking.CICPNL.R.id;
import com.smartthinking.CICPNL.home.objects.App_ImageLoader;
import com.smartthinking.CICPNL.home.objects.clsDictionary;
import com.smartthinking.CICPNL.home.xml.saxXML;

public class Calendario extends Activity {
	public ProgressDialog progressDialog;
	public ArrayList<Dictionary> Actividades;
	public ArrayList<Dictionary> ActividadesB;
	public App_ImageLoader imageLoader;
	public Gallery gallery1;
	public com.smartthinking.CICPNL.home.activity.Calendario.Hoteles_Adapter myAdapter;
	public ArrayList<Dictionary> gallery1_;
	public SimpleDateFormat formatter;
	public Gallery gallery2;
	public Gallery gallery3;
	public Gallery gallery4;
	public Gallery gallery5;
	public Gallery gallery6;
	public Gallery gallery7;
	public Gallery gallery8;
	public Gallery gallery9;
	public Gallery gallery10;
	public Gallery gallery11;
	public Gallery gallery12;

	public ArrayList<Dictionary> gallery2_;
	public ArrayList<Dictionary> gallery3_;
	public ArrayList<Dictionary> gallery4_;
	public ArrayList<Dictionary> gallery5_;
	public ArrayList<Dictionary> gallery6_;
	public ArrayList<Dictionary> gallery7_;
	public ArrayList<Dictionary> gallery8_;
	public ArrayList<Dictionary> gallery9_;
	public ArrayList<Dictionary> gallery10_;
	public ArrayList<Dictionary> gallery11_;
	public ArrayList<Dictionary> gallery12_;

	private ImageView iGallery1;
	private ImageView iGallery2;
	private ImageView iGallery3;
	private ImageView iGallery4;
	private ImageView iGallery5;
	private ImageView iGallery6;
	private ImageView iGallery7;
	private ImageView iGallery8;
	private ImageView iGallery9;
	private ImageView iGallery10;
	private ImageView iGallery11;

	private TextView fecha1;
	private TextView fecha2;
	private TextView fecha3;
	private TextView fecha4;
	private TextView fecha5;
	private TextView fecha6;
	private TextView fecha7;
	private TextView fecha8;
	private TextView fecha9;
	private TextView fecha10;
	private TextView fecha11;

	private String sfecha1;
	private String sfecha2;
	private String sfecha3;
	private String sfecha4;
	private String sfecha5;
	private String sfecha6;
	private String sfecha7;
	private String sfecha8;
	private String sfecha9;
	private String sfecha10;
	private String sfecha11;
	private Intent intent;
	public String sfecha12;
	protected String QRY_BUSCADOR = " select * from eventos where eve_publicado in (1,2) order by eve_fec_ini    ";
	public ListView list;
	public Hoteles_Adapter1 adapter;

	// select * from eventos where eve_publicado = 1 order by eve_fec_ini

	public void voidFinish(View V) {
		finish();

	}

	public void abrirMenuLateral(View V) {
		intent = new Intent(Calendario.this, MenuLateral.class);

		startActivity(intent);
	}

	@Override
	public void onBackPressed() {
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.ui_calendario);

		final EditText buscar = (EditText) this
				.findViewById(id.et_buscar_buscar);

		ImageView buscador = (ImageView) this.findViewById(id.imageView1);
		buscador.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				QRY_BUSCADOR = " select * from eventos where eve_publicado in (1,2) and (UPPER(eve_nombre) like UPPER('%"
						+ buscar.getText().toString().toUpperCase()
						+ "%') or UPPER(eve_nombre_en) like UPPER('%"
						+ buscar.getText().toString().toUpperCase()
						+ "%')) order by eve_fec_ini  ";

				setContentView(R.layout.ui_calendario_busqueda);

				CargarContenidoBusqueda();
				// abrirSplashBanner();
			}
		});

		CargarContenido();
		abrirSplashBanner();
	}

	public void onConfigurationChanged(Configuration newConfig) {
		super.onConfigurationChanged(newConfig);

		// Checks the orientation of the screen

	}

	public void abrirSplashBanner() {
		/** se obtiene datos **/

		Intent intent = new Intent(this, Splash.class);
		intent.putExtra("PUT_IMG_WEB", "CALENDARIO");
		startActivity(intent);

	}

	private void CargarContenido() {
		// TODO Auto-generated method stub
		new AsyncActividades().execute("contenido");

	}

	private void CargarContenidoBusqueda() {
		// TODO Auto-generated method stub
		new AsyncActividadesB().execute("contenido");

	}

	private class AsyncActividadesB extends AsyncTask<String, Void, Integer> {

		protected void onPostExecute(Integer in) {

			list = (ListView) findViewById(R.id.list);
			adapter = new Hoteles_Adapter1(ActividadesB);
			list.setAdapter(adapter);

			list.setTextFilterEnabled(true);

			list.setOnItemClickListener(new OnItemClickListener() {

				public void onItemClick(AdapterView<?> parent, View view,
						int position, long id) {

					abrirInformacionEvento(ActividadesB.get(position));
					//

					// finish();

				}
			});

			progressDialog.dismiss();

		}

		protected void abrirInformacionEvento(Dictionary d) {

			Intent intent = new Intent(Calendario.this, InformationEvento.class);
			clsDictionary.setDctionary(d);
			startActivity(intent);

		}

		protected void onPreExecute() {

			progressDialog = ProgressDialog.show(Calendario.this, "",
					"Cargando...");
		}

		protected Integer doInBackground(String... urls) {

			String qry_url = getString(R.string.QRY_URL)
					+ Uri.encode(QRY_BUSCADOR);

			saxXML saxparser = new saxXML(qry_url);

			ActividadesB = saxparser.parse();

			return null;

		}

	}

	/**
	 * select * from banners WHERE BAN_TIPO IN ( 'BANNER HOTELES 1','BANNER
	 * HOTELES 2','BANNER HOTELES 3') ORDER BY ban_idr
	 * 
	 * 
	 * **/

	private class AsyncActividades extends AsyncTask<String, Void, Integer> {

		protected void onPostExecute(Integer in) {

			// list = (ListView) findViewById(R.id.list);
			// adapter = new Hoteles_Adapter(ActividadesBanner);
			// list.setAdapter(adapter);
			//
			// list.setTextFilterEnabled(true);
			//
			// list.setOnItemClickListener(new OnItemClickListener() {
			// public void onItemClick(AdapterView<?> parent, View view,
			// int position, long id) {
			//
			// Intent intent = new Intent(Hoteles.this,
			// HotelesDetalle.class);
			//
			// clsDictionary.setDctionary(Actividades.get(position));
			//
			// startActivity(intent);

			// finish();

			// }
			// });

			/** Ciclo **/

			gallery1_ = new ArrayList<Dictionary>();

			gallery2_ = new ArrayList<Dictionary>();

			gallery3_ = new ArrayList<Dictionary>();

			gallery4_ = new ArrayList<Dictionary>();

			gallery5_ = new ArrayList<Dictionary>();

			gallery6_ = new ArrayList<Dictionary>();

			gallery7_ = new ArrayList<Dictionary>();

			gallery8_ = new ArrayList<Dictionary>();

			gallery9_ = new ArrayList<Dictionary>();

			gallery10_ = new ArrayList<Dictionary>();

			gallery11_ = new ArrayList<Dictionary>();

			gallery12_ = new ArrayList<Dictionary>();

			String actual = null;
			String siguiente = null;

			int size_ = Actividades.size();

			int gallery_case = 1;

			boolean fecha = false;

			for (int i = 0; i < size_; i++) {

				actual = Actividades.get(i).get("eve_fec_ini").toString();

				/** Temporalmente se valida la fecha en string **/

				if ((i + 1) != size_)
					siguiente = Actividades.get(i + 1).get("eve_fec_ini")
							.toString();
				else
					siguiente = "";

				switch (gallery_case) {
				case 1:

					gallery1_.add(Actividades.get(i));
					sfecha1 = actual;
					break;
				case 2:

					gallery2_.add(Actividades.get(i));
					sfecha2 = actual;
					break;
				case 3:

					gallery3_.add(Actividades.get(i));
					sfecha3 = actual;
					break;
				case 4:

					gallery4_.add(Actividades.get(i));
					sfecha4 = actual;
					break;
				case 5:

					gallery5_.add(Actividades.get(i));
					sfecha5 = actual;
					break;
				case 6:

					gallery6_.add(Actividades.get(i));
					sfecha6 = actual;
					break;
				case 7:

					gallery7_.add(Actividades.get(i));
					sfecha7 = actual;
					break;
				case 8:

					gallery8_.add(Actividades.get(i));
					sfecha8 = actual;
					break;
				case 9:

					gallery9_.add(Actividades.get(i));
					sfecha9 = actual;
					break;
				case 10:

					gallery10_.add(Actividades.get(i));
					sfecha10 = actual;
					break;
				case 11:

					gallery11_.add(Actividades.get(i));
					sfecha11 = actual;
					break;

				}

				try {
					if (!actual.substring(0, 7).equals(
							siguiente.substring(0, 7))) {
						gallery_case++;

					}
				} catch (Exception e) {
				}

			}

			DisplayMetrics metrics = new DisplayMetrics();
			Calendario.this.getWindowManager().getDefaultDisplay()
					.getMetrics(metrics);
			MarginLayoutParams mlp;
			try {
				gallery1 = (Gallery) findViewById(R.id.galery_calendario1);
				myAdapter = new Hoteles_Adapter(gallery1_);
				gallery1.setAdapter(myAdapter);

				// Gallery gallery = (Gallery) findViewById(R.id.gallery1);

				mlp = (MarginLayoutParams) gallery1.getLayoutParams();
				mlp.setMargins(-(metrics.widthPixels / 2 + 50), mlp.topMargin,
						mlp.rightMargin, mlp.bottomMargin);

				gallery1.setOnItemClickListener(new OnItemClickListener() {
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {

						// Toast.makeText(
						// Calendario.this,
						// gallery1_.get(position).get("eve_nombre")
						// .toString(), Toast.LENGTH_LONG).show();

						abrirInformacionEvento(gallery1_.get(position));

					}
				});

				fecha1 = (TextView) Calendario.this
						.findViewById(id.tv_calendario_fecha1);
				fecha1.setText(sfecha1.subSequence(0, 7));
			} catch (Exception e) {
			}

			try {
				gallery2 = (Gallery) findViewById(R.id.galery_calendario2);
				myAdapter = new Hoteles_Adapter(gallery2_);

				gallery2.setAdapter(myAdapter);

				// DisplayMetrics metrics = new DisplayMetrics();
				Calendario.this.getWindowManager().getDefaultDisplay()
						.getMetrics(metrics);

				// Gallery gallery = (Gallery) findViewById(R.id.gallery1);

				mlp = (MarginLayoutParams) gallery2.getLayoutParams();
				mlp.setMargins(-(metrics.widthPixels / 2 + 50), mlp.topMargin,
						mlp.rightMargin, mlp.bottomMargin);

				gallery2.setOnItemClickListener(new OnItemClickListener() {
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {

						abrirInformacionEvento(gallery2_.get(position));
					}
				});

				if (gallery2_.size() > 0) {
					iGallery2 = (ImageView) Calendario.this
							.findViewById(id.iv_calendar_2);
					iGallery2.setVisibility(iGallery2.VISIBLE);

					fecha2 = (TextView) Calendario.this
							.findViewById(id.tv_calendario_fecha2);
					fecha2.setText(sfecha2.subSequence(0, 7));
					fecha2.setVisibility(fecha2.VISIBLE);
				}

			} catch (Exception e) {
			}

			try {
				gallery3 = (Gallery) findViewById(R.id.galery_calendario3);
				myAdapter = new Hoteles_Adapter(gallery3_);

				gallery3.setAdapter(myAdapter);

				// DisplayMetrics metrics = new DisplayMetrics();
				Calendario.this.getWindowManager().getDefaultDisplay()
						.getMetrics(metrics);

				// Gallery gallery = (Gallery) findViewById(R.id.gallery1);

				mlp = (MarginLayoutParams) gallery3.getLayoutParams();
				mlp.setMargins(-(metrics.widthPixels / 2 + 50), mlp.topMargin,
						mlp.rightMargin, mlp.bottomMargin);

				gallery3.setOnItemClickListener(new OnItemClickListener() {
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {

						abrirInformacionEvento(gallery3_.get(position));
					}
				});

				if (gallery3_.size() > 0) {
					iGallery3 = (ImageView) Calendario.this
							.findViewById(id.iv_calendar_3);
					iGallery3.setVisibility(iGallery3.VISIBLE);

					fecha3 = (TextView) Calendario.this
							.findViewById(id.tv_calendario_fecha3);
					fecha3.setText(sfecha3.subSequence(0, 7));
					fecha3.setVisibility(fecha3.VISIBLE);
				}
			} catch (Exception e) {
			}

			try {

				gallery4 = (Gallery) findViewById(R.id.galery_calendario4);
				myAdapter = new Hoteles_Adapter(gallery4_);

				gallery4.setAdapter(myAdapter);

				// DisplayMetrics metrics = new DisplayMetrics();
				Calendario.this.getWindowManager().getDefaultDisplay()
						.getMetrics(metrics);

				// Gallery gallery = (Gallery) findViewById(R.id.gallery1);

				mlp = (MarginLayoutParams) gallery4.getLayoutParams();
				mlp.setMargins(-(metrics.widthPixels / 2 + 50), mlp.topMargin,
						mlp.rightMargin, mlp.bottomMargin);

				gallery4.setOnItemClickListener(new OnItemClickListener() {
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {

						abrirInformacionEvento(gallery4_.get(position));
					}
				});
				if (gallery4_.size() > 0) {
					iGallery4 = (ImageView) Calendario.this
							.findViewById(id.iv_calendar_4);
					iGallery4.setVisibility(iGallery4.VISIBLE);

					fecha4 = (TextView) Calendario.this
							.findViewById(id.tv_calendario_fecha4);
					fecha4.setText(sfecha4.subSequence(0, 7));
					fecha4.setVisibility(fecha4.VISIBLE);
				}

			} catch (Exception e) {
			}

			try {
				gallery5 = (Gallery) findViewById(R.id.galery_calendario5);
				myAdapter = new Hoteles_Adapter(gallery5_);

				gallery5.setAdapter(myAdapter);

				// DisplayMetrics metrics = new DisplayMetrics();
				Calendario.this.getWindowManager().getDefaultDisplay()
						.getMetrics(metrics);

				// Gallery gallery = (Gallery) findViewById(R.id.gallery1);

				mlp = (MarginLayoutParams) gallery5.getLayoutParams();
				mlp.setMargins(-(metrics.widthPixels / 2 + 50), mlp.topMargin,
						mlp.rightMargin, mlp.bottomMargin);

				gallery5.setOnItemClickListener(new OnItemClickListener() {
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {

						abrirInformacionEvento(gallery5_.get(position));

					}
				});
				if (gallery5_.size() > 0) {
					iGallery5 = (ImageView) Calendario.this
							.findViewById(id.iv_calendar_5);
					iGallery5.setVisibility(iGallery5.VISIBLE);

					fecha5 = (TextView) Calendario.this
							.findViewById(id.tv_calendario_fecha5);
					fecha5.setText(sfecha5.subSequence(0, 7));
					fecha5.setVisibility(fecha5.VISIBLE);
				}
			} catch (Exception e) {
			}

			try {
				gallery6 = (Gallery) findViewById(R.id.galery_calendario6);
				myAdapter = new Hoteles_Adapter(gallery6_);

				gallery6.setAdapter(myAdapter);

				// DisplayMetrics metrics = new DisplayMetrics();
				Calendario.this.getWindowManager().getDefaultDisplay()
						.getMetrics(metrics);

				// Gallery gallery = (Gallery) findViewById(R.id.gallery1);

				mlp = (MarginLayoutParams) gallery6.getLayoutParams();
				mlp.setMargins(-(metrics.widthPixels / 2 + 50), mlp.topMargin,
						mlp.rightMargin, mlp.bottomMargin);

				gallery6.setOnItemClickListener(new OnItemClickListener() {
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {

						abrirInformacionEvento(gallery6_.get(position));
					}
				});
				if (gallery6_.size() > 0) {
					iGallery6 = (ImageView) Calendario.this
							.findViewById(id.iv_calendar_6);
					iGallery6.setVisibility(iGallery6.VISIBLE);

					fecha6 = (TextView) Calendario.this
							.findViewById(id.tv_calendario_fecha6);
					fecha6.setText(sfecha6.subSequence(0, 7));
					fecha6.setVisibility(fecha6.VISIBLE);
				}

			} catch (Exception e) {
			}

			try {
				gallery7 = (Gallery) findViewById(R.id.galery_calendario7);
				myAdapter = new Hoteles_Adapter(gallery7_);

				gallery7.setAdapter(myAdapter);

				// DisplayMetrics metrics = new DisplayMetrics();
				Calendario.this.getWindowManager().getDefaultDisplay()
						.getMetrics(metrics);

				// Gallery gallery = (Gallery) findViewById(R.id.gallery1);

				mlp = (MarginLayoutParams) gallery7.getLayoutParams();
				mlp.setMargins(-(metrics.widthPixels / 2 + 50), mlp.topMargin,
						mlp.rightMargin, mlp.bottomMargin);

				gallery7.setOnItemClickListener(new OnItemClickListener() {
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {

						abrirInformacionEvento(gallery7_.get(position));

					}
				});
				if (gallery7_.size() > 0) {
					iGallery7 = (ImageView) Calendario.this
							.findViewById(id.iv_calendar_7);
					iGallery7.setVisibility(iGallery7.VISIBLE);

					fecha7 = (TextView) Calendario.this
							.findViewById(id.tv_calendario_fecha7);
					fecha7.setText(sfecha7.subSequence(0, 7));
					fecha7.setVisibility(fecha7.VISIBLE);
				}

			} catch (Exception e) {
			}

			try {
				gallery8 = (Gallery) findViewById(R.id.galery_calendario8);
				myAdapter = new Hoteles_Adapter(gallery8_);

				gallery8.setAdapter(myAdapter);

				// DisplayMetrics metrics = new DisplayMetrics();
				Calendario.this.getWindowManager().getDefaultDisplay()
						.getMetrics(metrics);

				// Gallery gallery = (Gallery) findViewById(R.id.gallery1);

				mlp = (MarginLayoutParams) gallery8.getLayoutParams();
				mlp.setMargins(-(metrics.widthPixels / 2 + 50), mlp.topMargin,
						mlp.rightMargin, mlp.bottomMargin);

				gallery8.setOnItemClickListener(new OnItemClickListener() {
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {

						abrirInformacionEvento(gallery8_.get(position));
					}
				});
				if (gallery8_.size() > 0) {

					iGallery8 = (ImageView) Calendario.this
							.findViewById(id.iv_calendar_8);
					iGallery8.setVisibility(iGallery8.VISIBLE);

					fecha8 = (TextView) Calendario.this
							.findViewById(id.tv_calendario_fecha8);
					fecha8.setText(sfecha8.subSequence(0, 7));
					fecha8.setVisibility(fecha8.VISIBLE);
				}

			} catch (Exception e) {
			}

			try {

				gallery9 = (Gallery) findViewById(R.id.galery_calendario9);
				myAdapter = new Hoteles_Adapter(gallery9_);

				gallery9.setAdapter(myAdapter);

				// DisplayMetrics metrics = new DisplayMetrics();
				Calendario.this.getWindowManager().getDefaultDisplay()
						.getMetrics(metrics);

				// Gallery gallery = (Gallery) findViewById(R.id.gallery1);

				mlp = (MarginLayoutParams) gallery9.getLayoutParams();
				mlp.setMargins(-(metrics.widthPixels / 2 + 50), mlp.topMargin,
						mlp.rightMargin, mlp.bottomMargin);

				gallery9.setOnItemClickListener(new OnItemClickListener() {
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {

						abrirInformacionEvento(gallery9_.get(position));
					}
				});
				if (gallery9_.size() > 0) {
					iGallery9 = (ImageView) Calendario.this
							.findViewById(id.iv_calendar_9);
					iGallery9.setVisibility(iGallery9.VISIBLE);

					fecha9 = (TextView) Calendario.this
							.findViewById(id.tv_calendario_fecha9);
					fecha9.setText(sfecha9.subSequence(0, 7));
					fecha9.setVisibility(fecha9.VISIBLE);
				}

			} catch (Exception e) {
			}

			try {

				gallery10 = (Gallery) findViewById(R.id.galery_calendario10);
				myAdapter = new Hoteles_Adapter(gallery10_);

				gallery10.setAdapter(myAdapter);

				// DisplayMetrics metrics = new DisplayMetrics();
				Calendario.this.getWindowManager().getDefaultDisplay()
						.getMetrics(metrics);

				// Gallery gallery = (Gallery) findViewById(R.id.gallery1);

				mlp = (MarginLayoutParams) gallery10.getLayoutParams();
				mlp.setMargins(-(metrics.widthPixels / 2 + 50), mlp.topMargin,
						mlp.rightMargin, mlp.bottomMargin);

				gallery10.setOnItemClickListener(new OnItemClickListener() {
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {

						abrirInformacionEvento(gallery10_.get(position));
					}
				});
				if (gallery10_.size() > 0) {
					iGallery10 = (ImageView) Calendario.this
							.findViewById(id.iv_calendar_10);
					iGallery10.setVisibility(iGallery10.VISIBLE);

					fecha10 = (TextView) Calendario.this
							.findViewById(id.tv_calendario_fecha10);
					fecha10.setText(sfecha10.subSequence(0, 7));
					fecha10.setVisibility(fecha10.VISIBLE);
				}

			} catch (Exception e) {
			}

			try {

				gallery11 = (Gallery) findViewById(R.id.galery_calendario11);
				myAdapter = new Hoteles_Adapter(gallery11_);

				gallery11.setAdapter(myAdapter);

				// DisplayMetrics metrics = new DisplayMetrics();
				Calendario.this.getWindowManager().getDefaultDisplay()
						.getMetrics(metrics);

				// Gallery gallery = (Gallery) findViewById(R.id.gallery1);

				mlp = (MarginLayoutParams) gallery11.getLayoutParams();
				mlp.setMargins(-(metrics.widthPixels / 2 + 50), mlp.topMargin,
						mlp.rightMargin, mlp.bottomMargin);

				gallery11.setOnItemClickListener(new OnItemClickListener() {
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {

						abrirInformacionEvento(gallery11_.get(position));
					}
				});
				if (gallery11_.size() > 0) {
					iGallery11 = (ImageView) Calendario.this
							.findViewById(id.iv_calendar_11);
					iGallery11.setVisibility(iGallery11.VISIBLE);

					fecha11 = (TextView) Calendario.this
							.findViewById(id.tv_calendario_fecha11);
					fecha11.setText(sfecha11.subSequence(0, 7));
					fecha11.setVisibility(fecha11.VISIBLE);
				}
			} catch (Exception e) {
			}

			progressDialog.dismiss();

		}

		protected void abrirInformacionEvento(Dictionary d) {

			Intent intent = new Intent(Calendario.this, InformationEvento.class);
			clsDictionary.setDctionary(d);
			startActivity(intent);

		}

		protected void onPreExecute() {

			progressDialog = ProgressDialog.show(Calendario.this, "",
					"Cargando...");
		}

		protected Integer doInBackground(String... urls) {

			String qry_url = getString(R.string.QRY_URL)
					+ Uri.encode(QRY_BUSCADOR);

			saxXML saxparser = new saxXML(qry_url);

			Actividades = saxparser.parse();

			return null;

		}

	}

	public class Hoteles_Adapter1 extends BaseAdapter {

		private LayoutInflater inflater = null;
		private ArrayList<Dictionary> data;

		public Hoteles_Adapter1(ArrayList<Dictionary> d) {

			data = d;
			inflater = (LayoutInflater) Calendario.this
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			//
			imageLoader = new App_ImageLoader(
					Calendario.this.getApplicationContext());

		}

		public int getCount() {
			return data.size();
		}

		public Object getItem(int position) {
			return position;
		}

		public long getItemId(int position) {
			return position;
		}

		public class ViewHolder {

			public ImageView icon;
			public TextView titulo;
			public TextView subtitulo;

		}

		public View getView(int position, View convertView, ViewGroup parent) {

			View vi = convertView;
			ViewHolder holder;

			if (convertView == null) {

				vi = inflater.inflate(R.layout.ui_calendario_busqueda_items,
						null);

				holder = new ViewHolder();

				holder.icon = (ImageView) vi
						.findViewById(R.id.iv_listview_items_imagen);

				holder.titulo = (TextView) vi
						.findViewById(id.tv_listview_items_titulo);

				holder.subtitulo = (TextView) vi
						.findViewById(id.tv_listview_items_subtitulo);

				vi.setTag(holder);

			} else

				holder = (ViewHolder) vi.getTag();

			holder.titulo.setText(data.get(position).get("eve_nombre")
					.toString());
			holder.subtitulo.setText("Inicio: "
					+ data.get(position).get("eve_fec_ini").toString()
					+ "  Fin:"
					+ data.get(position).get("eve_fec_fin").toString());

			String url_img = getString(R.string.QRY_URL_IMG)
					+ data.get(position).get("eve_poster").toString()
							.replace(" ", "%20");

			holder.icon.setTag(url_img);
			try {

				imageLoader.DisplayImage(url_img, Calendario.this, holder.icon);

			} catch (Exception ex) {

				String s = ex.getMessage().toString();

			}

			return vi;

		}

	}

	public class Hoteles_Adapter extends BaseAdapter {

		private LayoutInflater inflater = null;
		private ArrayList<Dictionary> data;

		public Hoteles_Adapter(ArrayList<Dictionary> d) {

			data = d;
			inflater = (LayoutInflater) Calendario.this
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			//
			imageLoader = new App_ImageLoader(
					Calendario.this.getApplicationContext());

		}

		public int getCount() {
			return data.size();
		}

		public Object getItem(int position) {
			return position;
		}

		public long getItemId(int position) {
			return position;
		}

		public class ViewHolder {

			public ImageView icon;

		}

		public View getView(int position, View convertView, ViewGroup parent) {

			View vi = convertView;
			ViewHolder holder;

			if (convertView == null) {

				vi = inflater.inflate(R.layout.ui_calendario_item, null);

				holder = new ViewHolder();

				holder.icon = (ImageView) vi
						.findViewById(R.id.iv_calendario_item_image);

				vi.setTag(holder);

			} else

				holder = (ViewHolder) vi.getTag();

			// holder.banner.setVisibility(holder.icon.GONE);
			//
			// holder.icon.setVisibility(holder.icon.VISIBLE);
			//
			// holder.vermas.setVisibility(holder.vermas.VISIBLE);
			//
			// String Nombre = data.get(position).get("poi_nombre").toString();
			// holder.tvTitulo.setText(Nombre);
			//
			// String Direccion = data.get(position).get("poi_direccion")
			// .toString();
			// holder.tvSubtitulo.setText(Direccion);
			//
			String url_img = getString(R.string.QRY_URL_IMG)
					+ data.get(position).get("eve_poster").toString()
							.replace(" ", "%20");

			holder.icon.setTag(url_img);
			try {

				imageLoader.DisplayImage(url_img, Calendario.this, holder.icon);

			} catch (Exception ex) {

				String s = ex.getMessage().toString();

			}

			return vi;

		}

	}

}
